package com.drg.center.controller;

import cn.hutool.core.lang.tree.Tree;
import com.drg.center.entity.result.SysDeptVO;
import com.drg.center.service.SysDeptService;
import com.guaike.core.entity.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: zhangxilin
 * @Date: 2024/5/15
 */
@RestController
@RequestMapping("/dept")
@Api(tags = "系统-部门接口组")
public class SysDeptController {

    @Autowired
    private SysDeptService sysDeptService;

    @GetMapping("/findTree")
    @ApiOperation(value = "部门树")
    public Result<List<Tree<String>>> findTree(@ApiParam("是否只查询启用的") @RequestParam("onlyEnable") Boolean onlyEnable){
        return sysDeptService.findTree(onlyEnable);
    }

    @GetMapping("/detail")
    @ApiOperation(value = "详情")
    public Result<SysDeptVO> detail(@ApiParam("科室编号") @RequestParam("departCode") String departCode){
        return sysDeptService.detail(departCode);
    }
}
